#ifndef _GEN_PUZZLE_STATE_H_
#define _GEN_PUZZLE_STATE_H_

namespace LuaPlus
{
	class LuaState;
}

#include "fig_mogaui_state.h"

#include "input/keyboard.h"
#include "input/moga.h"
#include "gameflow/ui_state.h"


class Fighter;
namespace gameflow
{
	class UIPopup;
}


class GENGameState : public FIGMOGAUIState 
{
public:
						GENGameState(camera::FbCamera*	pCamera, const std::string& UI, const std::string& OnEnter, const std::string& OnExit);
	
	/// called when the game flow manager transitions into this game state
	virtual	bool		OnEnter();

	/// called when the game flow manager transitions out of this game state
	virtual	bool		OnExit();

	/// render the help
	virtual	bool		PreRender();
	virtual	bool		PostRender();

	/// update the game
	virtual	bool		Tick(float dt);
	virtual void		KeyDown(input::Keyboard::KEY* pKey);
	virtual void		KeyPressed(input::Keyboard::KEY* pKey);
	virtual	void		MouseButtonPressed(input::Mouse::BUTTON_STATE* pKey, const math::Vec2& Pos);
	virtual	void		MouseButtonReleased(input::Mouse::BUTTON_STATE* pKey, const math::Vec2& Pos);
	virtual	void		MouseButtonDown(input::Mouse::BUTTON_STATE* pKey, const math::Vec2& Pos);
	virtual void		MouseMove(const math::Vec2& From, const math::Vec2& To);
	virtual void		MouseWheelMove(int WheelInfo, const math::Vec2& Pos);
	virtual void		LoseFocus();
	

	static GENGameState*	GetGame();
		

	void					Save(const std::string& File);

	static void				Register(LuaPlus::LuaState* _pScript);

	void					CachedLoad(const std::string& s);
	bool					HasCached() const { return !m_CachedLoad.empty(); };
	void					SetNextLevel(const std::string& Next) { m_NextLevel = Next; };
	const std::string&		GetNextLevel() const { return m_NextLevel; };
	void					ClearLevel();
	void					Pause();
	void					UnPause();

	void					OnLevelCompete();

	// MOGA
	virtual void			OnMOGAKeyDownEvent(int	KeyCode);
	virtual void			OnMOGAKeyUpEvent(int	KeyCode);
	virtual void			OnMOGAMotionEvent(float X, float Y, float Z);
	virtual void			OnMOGAStateEvent(int	State);
	

protected:

	// UI Stuffs
	void DELEGATE_CALL			OnButtonPause(ui::UIWidget::WIDGET_EVENT Event, ui::UIWidget* pWidget);



	void						MouseScroll(float dt);
	void						LoadFromFile(const std::string& File);

	gameflow::GameTransition*	m_pFrom;
	gameflow::GameTransition*	m_pTo;

	int							GetHint(const std::string& Name);
	ui::UIWidget*				m_pUI;
	

	math::Vec2					m_FocusPoint;
	std::string					m_Name, m_Pwd;
	std::string					m_CachedLoad;
	Fighter*					m_pGame;

	bool						m_IsDebugging;
	std::string					m_NextLevel;
	bool						m_bIsPause;


	ui::UIWidget*				m_pUIPause;
	ui::UIProgress*				m_pUIBossHealth;
	
	
	bool						m_IsConstantScreenShot;
	int							m_ConstantScreenShotIndex;
	bool						m_ToSkipConstantScreenShot;
	float 						m_DelayFontRecreate;
	


};


#endif //_GEN_PUZZLE_STATE_H_
